
<div id="content">
    <div smart-include="sensor/views/sub-header.tpl.html"></div>
    <div class="clearfix margin-bottom-10">
        <div class="pull-left margin-right-20">
            <a class="btn btn-labeled btn-primary" data-toggle="modal" data-target="#addAlert" ng-click="add_box()"> <span class="btn-label"><i class="glyphicon glyphicon-plus"></i></span>添加报警设置</a>
            <select class="input-sm" ng-model="insert.deviceid" ng-change="sele_pos(insert.deviceid)">
                <option ng-repeat="item in alldevice" value="{{item.deviceid}}">{{item.deviceid}}</option>
            </select>
        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-bordered table-hover no-margin font-sml table-striped sensor_table">
            <thead>
                <tr>
                    <th>操作</th>
                    <th class="text-align-center">设备编号</th>
                    <th class="text-align-center">报警类型</th>
                   <!-- <th class="text-align-center">字段名称</th>-->
                    <th class="text-align-center">报警字段</th>
                    <th class="text-align-center">报警值</th>
                    <th class="text-align-center">通知类型</th>
                    <th class="text-align-center">创建时间</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="data in datas">
                    <td>
                        <button class='btn btn-xs btn-default' uib-tooltip='编辑' tooltip-append-to-body='true' ng-click="showEditAlert(data)"><i class='fa fa-pencil'></i></button>
                        <button class='btn btn-xs btn-default' uib-tooltip='删除' tooltip-append-to-body='true' ng-click="showDelDialog(data.id)"><i class='fa fa-times'></i></button>
                    </td>
                    <td class="text-align-center deviceid">{{data.deviceid}}</td>
                    <td class="text-align-center">{{data.warn_type_name}}</td>
                    <!--<td class="text-align-center">{{data.fieldvalue}}</td>-->
                    <td class="text-align-center">{{data.fieldname}}</td>
                
                    <td class="text-align-center">{{data.value}}</td>
                    <td class="text-align-center">{{data.notice_type_name}}</td>
                    <td class="text-align-center">{{data.time}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <!-- end widget content -->
    <div class="dt-toolbar-footer">
        <tm-pagination conf="paginationConf"></tm-pagination>
    </div>
    <div class="modal fade" id="addAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title">添加警告设置</h4>
                </div>
                <div class="modal-body">
                    <form class="smart-form" data-smart-registration-form ng-submit="insertdata()">
                        <fieldset class="row">
                             <section class="col-sm-5" style="margin: 0 20px 15px;">
                                   <label class="label">设备编号</label>
                                     <label class="select">
                                         <select class="input-sm" ng-model="insert.deviceid" ng-change="sele_field(insert.deviceid)">
                                             <option ng-repeat="item in alldevice" value="{{item.deviceid}}">{{item.deviceid}}</option>
                                         </select>
                                         <i></i>
                                     </label>
                             </section> 
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警类型</label>
                                <label class="select">
                                    <select name="" required="required" ng-model="insert.warn_type" ng-change="sele_poc(insert.warn_type)">
                                        <option value="{{i.id}}" ng-repeat="i in caveat">{{i.name}}</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警字段</label>
                                <label class="select">
                                    <select name="" ng-model="insert.fieldname">
                                        <option value="{{police.COLUMN_NAME}}" ng-repeat="police in polices">{{police.column_comment}}</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-show="ziduan">
                                <label class="label">报警值</label>
                                <label class="select">
                                    <input class="form-control" ng-model="insert.value"/>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">通知类型</label>
                                <label class="select">
                                    <select name="" required="required" ng-model="insert.notice_type">
                                        <option value="{{i.id}}" ng-repeat="i in call">{{i.name}}</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-show="ziduan">
                                <label class="label">通知等级</label>
                                <label class="select">
                                    <select name="" required="required" ng-model="insert.warn_grade">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">转发地址</label>
                                <label class="select">
                                    <input class="form-control" ng-model="insert.postaddress"/>
                                </label>
                            </section>
                        </fieldset>
                        <footer>
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                关闭
                            </button>
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>

                        </footer>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="editAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">编辑警告设置</h4>
                </div>
                <div class="modal-body">
                    <form id="smart-form-register" class="smart-form" data-smart-registration-form ng-submit="updatedata()">
                        <fieldset class="row">
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">设备编号</label>
                                <label class="input">
                                    <input type="text" maxlength="50" required="required" ng-model="editdata.deviceid" ng-disabled="true">
                                </label>
                            </section> 

                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警类型</label>
                                <label class="select">
                                    <select name="" required="required" ng-model="editdata.warn_type" ng-change="sele_edit(editdata.warn_type)">
                                        <option value="{{i.id}}" ng-repeat="i in caveat">{{i.name}}</option>
                                    </select>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警字段</label>
                                <label class="select">
                                    <select name="" required="required" ng-model="editdata.fieldname">
                                        <option value="{{police.COLUMN_NAME}}" ng-repeat="police in polices">{{police.column_comment}}</option>
                                    </select>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-show="editziduan">
                                <label class="label">报警值</label>
                                <label class="select">
                                    <input class="form-control" ng-model="editdata.value"/>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">通知类型</label>
                                <label class="select">
                                    <select name="" required="required" ng-model="editdata.notice_type">
                                        <option value="0">不通知</option>
                                        <option value="1">短信通知</option>
                                        <option value="2">公众号通知</option>
                                        <option value="3">短信、公众号通知</option>
                                        <option value="4">转发通知</option>
                                    </select>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-show="editziduan">
                                <label class="label">通知等级</label>
                                <label class="select">
                                    <select name="" id="" required="required" ng-model="editdata.warn_grade">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                    </select>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">转发地址</label>
                                <label class="select">
                                    <input class="form-control" ng-model="editdata.postaddress"></input>
                                </label>
                            </section>
                        </fieldset>
                        <footer>
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                关闭
                            </button>
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>
                        </footer>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="showDelDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title">信息</h4>
                </div>
                <div class="modal-body">
                    <p>
                        您确实要删除这个报警设置吗？
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" ng-click="deldevice()">
                        删除
                    </button>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
    <!-- /.modal-dialog -->
</div>
 <!-- END MAIN CONTENT -->